package com.ay272.sshupdate.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

/**
 * 等同于Spring mvc 的xml
 *
 * Created by Administrator on 2016/5/23.
 */
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.ay272.sshupdate",includeFilters = {@ComponentScan.Filter(value={Controller.class})},useDefaultFilters = false)
public class WebConfig extends WebMvcConfigurerAdapter {
    /*
    * jsp  试图解决方案
    * */
@Bean
     public InternalResourceViewResolver internalResourceViewResolver(){
      InternalResourceViewResolver bean=new InternalResourceViewResolver();
         bean.setViewClass(JstlView.class);
         bean.setPrefix("/WEB-INF/JSP/");
         bean.setSuffix(".jsp");

         return bean;
     }
    @Bean
    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(){
        MappingJackson2HttpMessageConverter bean=new MappingJackson2HttpMessageConverter();
        return bean;
    }
}
